package com.android.views;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

public class GaysActivity extends Activity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_gays);

		ListView theListView = (ListView) findViewById(R.id.theListView);
		final EditText theEditText = (EditText) findViewById(R.id.theEditText);
		
		//create the array list of todo items
		final ArrayList<String> toDoItems = new ArrayList<String>();
		//create the array adapter to bind the array to the list view
		final ArrayAdapter<String> aa;
		aa = new ArrayAdapter<String>(this,
									  android.R.layout.simple_list_item_1,
									  toDoItems);
		//Bind the array adapter to the ListView
		theListView.setAdapter(aa);
		
		
		//10
		theEditText.setOnKeyListener(new View.OnKeyListener() {
			
			@Override
			public boolean onKey(View v, int keycode, KeyEvent event) {
				if(event.getAction() == KeyEvent.ACTION_DOWN){
					if((keycode == KeyEvent.KEYCODE_DPAD_CENTER) ||
					   (keycode == KeyEvent.KEYCODE_DPAD_CENTER) 	){
							toDoItems.add(0,theEditText.getText().toString());
							aa.notifyDataSetChanged();
							theEditText.setText("");
							return true;
					}
				}
				return false;
			}
		});
		
	}
}
